<?php
	$dir = dirname(__FILE__);
	$concat = '';
	
	if ($handle = opendir("$dir/../js")) {

	    /* This is the correct way to loop over the directory. */
	    while (false !== ($file = readdir($handle))) {
	        if(strpos($file, ".js") !== false)
				$concat .= file_get_contents("$dir/../js/$file");
	    }
	
	    closedir($handle);
	}
	
	echo $concat;
?>